package scenic;

import java.awt.Rectangle;

import scenic.geom.Affine2;

/**
 * This scene node transforms its children using a 2-dimensional 
 * affine transformation.
 */
public class SceneTransform extends SceneContainer {
	private Affine2 transform;

	/**
	 * Creates a SceneTransform object with the given transform.
	 * 
	 * @param transform the transform.
	 */
	public SceneTransform(Affine2 transform) {
		this.transform = transform;
	}
	
	/**
	 * Gets the transformation.
	 */
	public Affine2 getTransform() {
		return transform;
	}

	/**
	 * Sets the transformation.
	 */
	public void setTransform(Affine2 transform) {
		this.transform = transform;
		changed();
	}

	void draw(DrawContext context, Affine2 transform, Rectangle visibleArea) {
		super.draw(context, Affine2.multiply(transform, this.transform), visibleArea);
	}
	
	Rectangle getBounds(Affine2 transform) {
		return super.getBounds(Affine2.multiply(this.transform, transform));
	}

	int getDrawType(Affine2 transform) {
		return super.getDrawType(Affine2.multiply(this.transform, transform));
	}		
}
